﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KCMS.DataAcsess.Interfaces;
using KCMS.DataAcsess.Entitys;
namespace KCMS.DataAcsess.Engine
{
    public class BrendManager : IBrendManager
    {

        protected DataClassesDataContext db = new DataBaseConnect().DataBase;
        private DataManager<BrendEntity> dm = new DataManager<BrendEntity>();
        public BrendEntity getById(Guid id)
        {
            return (from t in db.GetTable<BrendEntity>()
                    where t.Id.Equals(id)
                    select t).SingleOrDefault();
        }
        public IEnumerable<BrendEntity> getAll()
        {

            return dm.getAll();
        }

        public void delete(Guid id)
        {

            dm.delete(id);
        }

        public void update(BrendEntity brend)
        {
            db = new DataBaseConnect().DataBase;
            var old = getById(brend.Id);
            old.CopyPropyties(brend);
            db.SubmitChanges();
        }

        public void save(BrendEntity brend)
        {

            dm.save(brend);
        }

    }
}
